package zero.tech.redis.topic;

import java.util.HashMap;
import java.util.Map;

import zero.tech.core.find.DynamicFind;


public class TopicManager extends DynamicFind {
	private Map<String, RedisTopicProcess> processMap = new HashMap<String, RedisTopicProcess>();
	@Override
	public void afterFind() {
	}
	@Override
	public void beforeFind() {
	}
	@Override
	public boolean verification(Class<?> clazz) {
		return superClassOn(clazz, TopicProcess.class);
	}
	private TopicManager() {
	}
	private static TopicManager manager = new TopicManager();
	public static TopicManager getManager(){
		return manager;
	}
	@Override
	public void findClass(Class<?> clz) throws Exception {
		RedisTopicProcess redisMqOrderProcess = (RedisTopicProcess) clz
				.newInstance();
		if (null == redisMqOrderProcess.orderType()
				|| "".equals(redisMqOrderProcess.orderType())) {
			throw new Exception("cmdOrder涓嶈兘涓虹┖鎴栫┖瀛楃涓� CLASS:"
					+ clz.getSimpleName());
		}
		this.processMap.put(redisMqOrderProcess.orderType() + "-"
				+ redisMqOrderProcess.channelType().getChannelType(),
				redisMqOrderProcess);
	}

	public RedisTopicProcess getRedisMqOrderProcess(String redisOrder,
			String channel) {
		RedisTopicProcess process = processMap.get(redisOrder + "-" + channel);
		return process;
	}
}
